package com.itheima.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import org.springframework.boot.web.servlet.ServletComponentScan;

import java.io.IOException;

//过滤器测试,并不使用
//@WebFilter(urlPatterns = "/*")
public class DemoFilter implements Filter {

    @Override//1
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
        System.out.println("init开始执行");
    }

    @Override//拦截到请求之后调用多次
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("doFilter开始执行");
        //放行
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override//1
    public void destroy() {
        System.out.println("destory开始执行");
        Filter.super.destroy();
    }
}



